<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>China FullFill</title>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.loading.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" SRC="/js/jquery.uploadify.min.js"></script>
<script type="text/javascript" SRC="/js/swfobject.js"></script>
<script type="text/javascript" SRC="/js/jquery-ui.js"></script>
<script type="text/javascript" SRC="/js/jquery.pagination.js"></script>
<script type="text/javascript" SRC="/js/product.picture.upload.js"></script>

<link rel="stylesheet" href="/css/uploadify.css" type="text/css" />
<link rel="stylesheet" href="/css/product-info.css" type="text/css" />
<link rel="stylesheet" href="/css/blitzer/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="/css/pagination.css" type="text/css" />

<script type="text/javascript" src="/js/jquery.fancybox.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox-thumbs.css" />
<script type="text/javascript" src="/js/jquery.fancybox-thumbs.js"></script>

<script type="text/javascript">
	
	$(function(){
		$('.fancybox-thumbs').fancybox({
			prevEffect	: 'none',
			nextEffect	: 'none',
			helpers	: {
				title	: {
					type: 'outside'
				},
				overlay	: {
					opacity : 0.8,
					css : {
						'background-color' : '#000'
					}
				},
				thumbs	: {
					width	: 50,
					height	: 50
				}
			}
		});	
	})
</script>

<style type='text/css'>
.col_red{color:red;}
.height111 {
    height: 28px;
    overflow: hidden;
}
.per101 {
    width: 10%;
}
.per102 {
    width: 15%;
}
.per103 {
    width: 25%;
}

.per104 {
    width: 48%;
}
</style>
<script type="text/javascript">
var productId = <{$productId}>;
var product_is_qc = <{$product_is_qc}>;
var customerId = "<{$customerId}>";
var paginationPageSize = 20;
var paginationCurrentPage = 1;
var paginationTotal;
var currentTab = 0;
function showinput(obj){
	if(!obj){
		$(".pocidCheckbox:checked").each(function(i){
			$('#put'+this.id).attr('readonly',false).css({"border":"1px solid #CCCCCC","background":"white"});
		});
	}else{
	    obj.checked ? $('#put'+obj.id).attr('readonly',false).css({"border":"1px solid #CCCCCC","background":"white"}) : $('#put'+obj.id).attr('readonly',true).css({"border":"none","background":"none"});
	}
}
	
$(function(){
	
		$("#qcItemCheck").dialog({
			autoOpen : false,
			width : 500,
			modal : true,
			show : "slide",	
			buttons : {
				'Close' : function(){ $(this).dialog('close');}
			}
		});
		
		$("#tip").dialog({
			autoOpen:false,
			modal:true,
			close:function(){
				//window.close();
			},
			buttons:{
				"close":function(){
					$(this).dialog("close");
				}
			}
		});
	
		$(".tab-li").click(function(){
			$(".tab-li-click").removeClass("tab-li-click");
			$(this).addClass("tab-li-click");
		});

		$(".tab-li:eq(7)").click(function(){
			loading();
			$.ajax({
				url:"/product/product/get-quanlity-control/productId/"+productId,
				dataType:"json"	,
				async:false,
				success:function(json){
					var html='<form id="qcEditForm" method="post"><div class="row height25 row-header"><div class="cell per20">Choice</div><div class="cell per30">Option Name</div><div class="cell per50">Option Value</div></div>';
					$.each(json,function(k,v){
						var bool = v.po_value ? true : false;
						html += '<div class="row height25"><div class="cell per20"><input id="'+v.poc_id+'" type="checkbox" value="'+v.poc_id+'" class="pocidCheckbox" name="pocid['+v.poc_id+']" '+(bool ? 'checked' : '')+' disabled="true" onclick="showinput(this)" style="margin-top:6px;"></div><div class="cell per30"><input type="hidden" name="poid" value="'+v.po_id+'">'+v.poc_value+'</div><div class="cell per50"><input name="opvalue['+v.poc_id+']" id="put'+v.poc_id+'" value="'+v.po_value+'" type="text" readonly="true" style="border:none; background:#F2F8FD;width:98%;height:17px; margin-top:3px;"></div></div>';			
					})
					html += '<div class="row height25"><div class="cell per100"><input type="button" value="Submit" class="btn btn-green " style="display:none;" name="qc_submit"/><input type="button" value="Edit" class="btn btn-green" name="qc_modify"/><input type="button" value="Cancel" class="btn btn-green " style="display:none;" name="qc_cancel"/></div></div></form>';
					$(".info-content-body").html(html);
					$("[name=qc_modify]").click(function(){
							$(".pocidCheckbox").attr({'disabled':false});
							showinput(null);
							$("[name=qc_cancel]").show();
							$("[name=qc_submit]").show();
							$("[name=qc_modify]").hide();
						});
					$("[name=qc_cancel]").click(function(){
						$(".tab-li:eq(6)").click();
					});
					
					$("[name=qc_submit]").click(function(){
						//检查如果<{$lang.pls}>了<{$lang.quanlity}> 就应至少保留一项<{$lang.quanlity}>项
						if(product_is_qc==1){
							var len = $('.pocidCheckbox:checked').length;
							var html = '';
							if(len==0){ 
								html+='Please select at least one when you choose need quality inspecion !';
								$("#qcItemCheck").html(html);
								$("#qcItemCheck").dialog('open');
								return false;
							}else{
								var temp = 0;
								$.each($('.pocidCheckbox:checked'),function(){
									if($('#put'+this.id).val()=='') temp++;
								});
								if(temp!=0){
									html+= 'The QC selected options\'s option value can\'t be empty !';
									$("#qcItemCheck").html(html);
									$("#qcItemCheck").dialog('open');
									return false;
								}	
							} 	
						}
						var opts = {
							url:"/product/product/quanlity-control-edit/productId/"+productId,
							dataType:'json',
							success:function(data){
								if(data.ask){ $(".tab-li:eq(7)").click(); }
							}
						};
						$("#qcEditForm").ajaxSubmit(opts);
					});
					closeLoading();
				}
			});	
		});
		
		$(".tab-li:eq(0)").click(function(){
			loading();
			$.ajax({
				url:"/product/product/baseinfos/productId/"+productId+"/"+new Date(),
				dataType:"json",
				async:false,
				success:function(json){
					if(json == null){
						closeLoading();
						$("#tip").dialog("open");
						 return;
					}
					if(json.ask){
						var canEdit = json.result.product.product_warehouse_status==1||json.result.product.ps_quantity>0?false:true;//第一次<{$lang.receive}>，不能<{$lang.edit}>
						
						var html = '<div class="tab-div"><form id="editForm" method="post">';
						html += '<input type="hidden" value="'+json.result.product.product_id+'" name="productId"/>';
						$.each(json.result.selectOptions,function(k,v){
							if(v.id==4) return;
							var autoGenerateText = "";
							html += '<div class="row height25"><div class="left bold">'+v.name+'：';
							html += '</div><div class="middle">';
							if(v.po_choose_type == 0){
								html += '<select type="text" class="autoGenerate"  value="" name="autoGenerate_'+v.id+'" style="width:200px"><option value="">Please Selected</option>';
									$.each(v.options,function(oK,oV){
										html += '<option value="'+oV.poc_id+'"';
											$.each(json.result.product.pov,function(poK,poV){
												if(oV.po_id == poV.po_id && oV.poc_id == poV.poc_id){
													html += ' selected';
													autoGenerateText = oV.poc_value;
												}
											});
											
										html += '>'+oV.poc_value+'</option>';
									});
								html += '</select>';
							}else{
								html += '<input type="text" id=""  value="';
								$.each(json.result.product.pov,function(poK,poV){
									if(v.id == poV.po_id){
										html += poV.po_value;
									}
								});
								html += '" name="autoGenerate_'+v.id+'" class="input-width-2 inputF autoGenerate1"/>';
							}
							html += '<span class="autoGenerateText">'+autoGenerateText+'</span>';
							if(v.required == 1){
								html += '<span class="red">&nbsp;&nbsp;*</span>';
							}
							html += '</div><div class="right">'+v.desc+'</div></div>';
						
						});
						
						
						html += '<div class="row height25"><div class="left bold"><{$lang.sku}> Name：</div><div class="middle"><input type="text" class="input-width-2 inputF" name="productName" value="'+json.result.product.product_title+'"/><span class="red">&nbsp;&nbsp;*</span></div><div class="right">Please begin with a letter or underscore</div></div>';
						
						html += '<div class="row height25"><div class="left bold">Chinese Name：</div><div class="middle"><input type="text" class="input-width-2 inputF" name="productCname" value="'+json.result.product.product_title_cn+'"/><span>&nbsp;&nbsp;</span></div><div class="right">Product Chinese Name</div></div>';
						
						html += '<div class="row height25"><div class="left bold"><{$lang.sku}>：</div><div class="middle">'+json.result.product.product_sku+'<input type="hidden" class="input-width-2 inputF" name="productNumber" value="'+json.result.product.product_sku+'"/><span class="red">&nbsp;&nbsp;*</span></div><div class="right">Please begin with a letter or underscore</div></div>';
						html += '<div class="row height25"><div class="left bold">Weight：</div><div class="middle"><input type="text" class="input-width-2 inputF" name="weight" value="'+json.result.product.product_weight+'"/>&nbsp;&nbsp;kg<span class="red">&nbsp;&nbsp;*</span></div><div class="right">Must be numeric</div></div>';
						html += '<div class="row height25"><div class="left bold">Volume：</div><div class="middle">Length:<input type="text" class="input-width-4 inputF" name="lenght" value="'+json.result.product.product_length+'" />&nbsp;&nbsp;Width:<input type="text" class="input-width-4 inputF"  name="width" value="'+json.result.product.product_width+'" />&nbsp;&nbsp;Height:<input type="text" class="input-width-4 inputF" value="'+json.result.product.product_height+'"  name="height" />&nbsp;&nbsp;cm</div><div class="right">Must be numeric</div></div>';
						html += '<div class="row height25"><div class="left bold">Declare Value：</div><div class="middle"><input type="text" class="input-width-2 inputF" style="width:245px" name="declareWorth" value="'+json.result.product.product_declared_value+'" />&nbsp;USD<span class="red">&nbsp;&nbsp;*</span></div><div class="right">Must be numeric</div></div>';
						
						html += '<div class="row height25"><div class="left bold">Quality Control ：</div><div style="display:inline-block;overflow:hidden;width:290px;height:18px !important;"><input disabled="disabled" name="product_isqc" value="1" type="checkbox" '+(json.result.product.product_is_qc==1 ? 'checked' : '')+'></div><div class="right">Please choose QC or not</div></div>';
						
						html += '<div class="row"><div class="left bold">Image：</div><div class="middle500">';
						html += '<div class="product-img-view" id="imagePlaceholder">No Image</div>';
//						html += '<span class="button-2 uploadFile">Local Image</span><br />';
//						html += '<span class="button-2 addLinkPicture">Web Image</span><br /><p>Click image to delete</p>';
						html += '</div></div>';
						
						
						if(canEdit){
							html += '<div class="row height25"><div class="left bold"></div><div class="middle text-middle"><input type="button" value="Submit" class="btn btn-green " name="submit"/><input type="button" value="Edit" class="btn btn-green " name="modify"/><input type="button" value="Cancel" class="btn btn-green " name="cancel"/></div></div></form></div>';
							html += '<div class="row"><div class="error"></div></div>';
						}else{
							html += '<div class="row height25"><div class="left bold"></div><div class="middle text-middle"><input type="button" value="Submit" class="btn btn-green " name="updateQty"/><input type="button" value="modifyQty" class="btn btn-green " name="modifyQty"/><input type="button" value="Cancel" class="btn btn-green " name="cancel"/></div></div></form></div>';
							html += '<div class="row"><div class="error"></div></div>';
						}

						
						$(".info-content-body").html(html);
						var iWidth = $("#imagePlaceholder").width();
						var iHeight = $("#imagePlaceholder").height();
						var html_img='';
						$.each(json.result.pictures,function(k,v){
							$("#imagePlaceholder").remove();
							
							
							if(v.pa_file_type=='img'){
							    
							$(".middle500").append('<div class="product-img-view"><a class="fancybox-thumbs" data-fancybox-group="thumb" href="/product/product/view-picture/id/'+v.product_id+'"><img src="/product/product/view-picture/id/'+v.product_id+'" width='+ iWidth +' height='+iHeight+'/><input type="hidden" name="picture[]" value="'+v.pa_path+'"/></a></div>');
							$("product-img-view").css("text-indent","0");
							if($(".product-img-view").length > 3){
								$("#height110").removeClass("height110");
							}
							    
								//html_img += '<div><img src="/product/product/view-picture/id/'+v.product_id+'\" width='+iWidth+'px height='+iHeight+'px></div>';
							}else{
							    //alert(v.pa_path);
								//html_img += '<div><img src="'+v.pa_path+'\" width='+iWidth+'px height='+iHeight+'px></div>';
								$(".middle500").append('<div class="product-img-view"><a class="fancybox-thumbs" data-fancybox-group="thumb" href="'+v.pa_path+'"><img src="'+v.pa_path+'" width='+ iWidth +' height='+iHeight+'/><input type="hidden" name="picture[]" value="'+v.pa_path+'"/></a></div>');
							$("product-img-view").css("text-indent","0");
							if($(".product-img-view").length > 3){
								$("#height110").removeClass("height110");
							}
							}
							
						});
						//$("#imagePlaceholder").html(html_img);
						
						
						$.each(json.result.links,function(k,v){
							$("#imagePlaceholder").remove();
							$(".uploadFile").before('<div class="product-img-view"><img src="'+v.pa_path+'" width='+ iWidth +' height='+iHeight+'/><input type="hidden" name="link[]" value="'+v.pa_path+'"/></div>');
							$("product-img-view").css("text-indent","0");
							if($(".product-img-view").length > 3){
								$("#height110").removeClass("height110");
							}
						});
						$(".inputF").attr("readonly",true);
						$(".inputF").css("border","none");
						$(".inputF").css("background","#FFF8DB");
						$(".red").hide();
						$(".right").hide();
						$("[name=submit]").hide();
						$("[name=cancel]").hide();
						$("[name=updateQty]").hide();
						$(".uploadFile").hide();
						$(".addLinkPicture").hide();
						$(".autoGenerate").hide();
						$(".autoGenerateText").show();
						
						$("[name=modify]").click(function(){
							$(".inputF").attr("readonly",false);
							$(".inputF").css("border","1px solid black");
							$(".inputF").css("background","white");
							$('[name=product_isqc]').attr('disabled',false);
							$(".red").show();
							$(".right").show();
							$("[name=submit]").show();
							$("[name=cancel]").show();
							$("[name=modify]").hide();
							$(".uploadFile").show();
							$(".addLinkPicture").show();
							$(".autoGenerate").show();
							$(".autoGenerateText").hide();
							$(".product-img-view").bind("click",function(){
								removePicture(this);
							});
						});
						$("[name=modifyQty]").click(function(){
							$(".inputF").attr("readonly",true);
							$(".inputF").css("border","none");
							$(".inputF").css("background","#FFF8DB");
							$(".red").show();
							$(".right").show();
							$("[name=updateQty]").show();
							$("[name=cancel]").show();
							$("[name=modifyQty]").hide();
							$(".uploadFile").show();
							$(".addLinkPicture").show();
							$(".autoGenerate").hide();
							$(".autoGenerateText").show();
							$(".autoGenerate1").show();
							$(".autoGenerate1").attr("readonly",false);
							$(".autoGenerate1").css("border","1px solid black");
							$(".autoGenerate1").css("background","white");
							
							$(".product-img-view").bind("click",function(){
								removePicture(this);
							});
						});
						$("[name=cancel]").click(function(){
							$(".inputF").attr("readonly",true);
							$(".inputF").css("border","none");
							$(".inputF").css("background","#FFF8DB");
							$(".red").hide();
							$(".right").hide();
							$("[name=submit]").hide();
							$("[name=cancel]").hide();
							$("[name=modify]").show();
							$(".product-img-view").unbind("click");
							$(".uploadFile").show();
							$(".addLinkPicture").show();
							$(".autoGenerate").hide();
							$(".autoGenerateText").show();
							$(".tab-li:eq(0)").click();
						});			
						
						$("[name=submit]").bind("click",function(){
							var opts = {
								url:"/product/product/edit",
								dataType: 'json', 
								success: function(data) {
									if(data.ask){
										loadProduct();										
										$(".tab-li:eq(0)").click();
										$("#tip").html(data.result).dialog("open");										
									}else{
										var err = "";
										$.each(data.result.errors,function(k,v){
											err += v+"<br/>";
										});
										$(".error").html(err);
									}
								}
							};
							$("#editForm").ajaxSubmit(opts);
						});
						
						$("[name=updateQty]").bind("click",function(){
							var opts = {
								url:"/product/product/update-qty",
								dataType: 'json', 
								success: function(data) {
									if(data.ask){
										loadProduct();										
										$(".tab-li:eq(0)").click();
										$("#tip").html(data.result).dialog("open");										
									}else{
										var err = "";
										$.each(data.result.errors,function(k,v){
											err += v+"<br/>";
										});
										$(".error").html(err);
									}
								}
							};
							$("#editForm").ajaxSubmit(opts);
						});
						closeLoading();
					}
				}
			});
		});
		
		$(".tab-li:eq(1)").click(function(){//获得<{$lang.log}><{$lang.msg}>
			if(currentTab!=1){
				paginationCurrentPage = 1;
			}
			currentTab = 1;
			loading();
			$.ajax({
				url:"/product/product/get-product-log/productId/"+productId+"/page/"+paginationCurrentPage+"/pageSize/"+paginationPageSize+"/"+new Date(),
				dataType:"json",
				async:false,
				success:function(json){
					if(json.ask){
						var html = '<div class="row height25 row-header"><div class="per10  cell">Type</div><div class="per15 cell">From Status</div><div class="per15 cell">To Status</div><div class="per30 cell">Detail</div><div class="per15 cell">Edit Date</div><div class="per14 cell no-background">IP</div></div>';
						$.each(json.result.logs,function(k,v){
							html += '<div class="row height110"><div class="per10  cell height110 line-height110" title="'+v.type+'">'+v.type+'</div><div class="per15 cell height110 line-height110" title="'+v.statu_pre+'">'+v.statu_pre+'</div><div class="per15 cell height110 line-height110" title="'+v.statu_now+'">'+v.statu_now+'</div><div class="per30 text-left height110 cell" title="'+v.ph_note+'">'+v.ph_note+'</div><div class="per15 cell height110 line-height110" title="'+v.ph_add_time+'">'+v.ph_add_time+'</div><div class="per14 cell height110  line-height110 no-background" title="'+v.ph_ip+'">'+v.ph_ip+'</div></div>'
						});
						html += '<div class="pagination" style="padding-top:10px" title="log"></div>';
						$(".info-content-body").html(html);
						$(".pagination").pagination(json.result.total, { 
							  callback: function(page_id){
								paginationCurrentPage = page_id+1;
								paginationTotal = json.result.total;
								$(".tab-li:eq(1)").click();
							  },
							  first_text:'First',
							  prev_text: '< Previous', 
							  next_text: 'Next >', 
							  last_text: 'Last',
							  perpage_text: 'PerPage',
							  total_text: 'Total',
							  items_per_page: paginationPageSize, 
							  num_display_entries: 6, 
							  current_page: paginationCurrentPage - 1, 
							  num_edge_entries: 2 
						 });
					}
					closeLoading();
				}
			});
			
		});
		
		$(".tab-li:eq(2)").click(function(){//<{$lang.product}><{$lang.picture}>
			if(currentTab!=2){
				paginationCurrentPage = 1;
			}
			currentTab = 2;
			loading();
			$.ajax({
				url:"/product/product/get-product-pictures/productId/"+productId+"/"+new Date(),
				dataType:"json",
				async:false,
				success:function(json){
					if(json.ask){
						var html = "";
						$.each(json.result.pictures,function(k,v){
							if(v.pa_file_type=='img'){
								html += '<div class="product-img-view"><a class="fancybox-thumbs" data-fancybox-group="thumb" href="/product/product/view-picture/id/'+v.product_id+'"><img src="/product/product/view-picture/id/'+v.product_id+'" width=100 height=100/></a></div>';
							}else{
								html += '<div class="product-img-view"><a class="fancybox-thumbs" data-fancybox-group="thumb" href="'+v.pa_path+'"><img src="'+v.pa_path+'" width=100 height=100/></a></div>';
							}

						});
						$(".info-content-body").html(html);
						closeLoading();
					}
				}
			});
		});
		
		$(".tab-li:eq(3)").click(function(){	//<{$lang.order}>
			if(currentTab!=3){
				paginationCurrentPage = 1;
			}
			currentTab = 3;		
			loading();
			$.ajax({
				url:"/product/product/get-orders/productId/"+productId+"/page/"+paginationCurrentPage+"/pageSize/"+paginationPageSize+"/"+new Date(),
				async:false,
				dataType:"json",
				success:function(json){
				
					if(json.ask){
						var html = '<div class="row height25 row-header">' +
								'<div class="width10 no-background">orders code</div>' +
								'<div class="width10 no-background">product quantity</div>' +
								'<div class="width10 no-background">order status</div>' +
								'<div class="width10 no-background">add_time</div>' +
								'</div>';
						if(json.result.logs.length){							
							
							$.each(json.result.logs,function(k,v){
								html += '<div class="row height25">' +
											'<div class="width10 no-background" title="'+v.type+'">'+
											v.orders_code+
											'</div>' +
											'<div class="width10 no-background" title="'+v.op_quantity+'">'+
											v.op_quantity+
											'</div>' +
											'<div class="width10 no-background" title="'+v.op_quantity+'">'+
											v.order_status+
											'</div>' +
											'<div class="width10 no-background" title="'+v.add_time+'">'+
											v.op_last_update+
											'</div>' +
										'</div>'
							});
							
							html += '<div class="pagination" style="padding-top:10px" title="log"></div>';
							$(".info-content-body").html(html);	
							$(".pagination").pagination(json.result.total, { 
								  callback: function(page_id){
									paginationCurrentPage = page_id+1;
									paginationTotal = json.result.total;
									$(".tab-li:eq(3)").click();
								  },
								  first_text:'First',
								  prev_text: '< Previous', 
								  next_text: 'Next >', 
								  last_text: 'Last',
								  perpage_text: 'PerPage',
								  total_text: 'Total',
								  items_per_page: paginationPageSize, 
								  num_display_entries: 6, 
								  current_page: paginationCurrentPage - 1, 
								  num_edge_entries: 2 
							 });
						}else{
							html += '<div class="row height25" style="text-align:center;">No data returns</div>'							
							$(".info-content-body").html(html);
						}					
					}else{
						var html = '<div class="row height25 row-header"><div class="per14 cell no-background">no result</div></div>';
						$(".info-content-body").html(html);
					}
					closeLoading();
				}
			});
		});
		
		$(".tab-li:eq(4)").click(function(){
			$(".info-content-body").html("");
			
		});

		$(".tab-li:eq(5)").click(function(){
			if(currentTab!=5){
				paginationCurrentPage = 1;
			}
			currentTab = 5;
			loading();
			$.ajax({
				url:"/product/product/shelf-log/productId/"+productId+"/page/"+paginationCurrentPage+"/pageSize/"+paginationPageSize+"/"+new Date(),
				async:false,
				dataType:"json",
				success:function(json){
					if(json.ask){
						var html = '<div class="row height25 row-header"><div class="per101  cell">ID</div><div class="per101  cell">Quantity</div><div class="per101 cell">QuantityHold</div><div class="per101 cell">CreateDate</div><div class="per101 cell">LastUpdate</div></div>';
						$.each(json.results,function(k,v){
						    var n=k+1;
							html += '<div class="row height111"><div class="per101  cell height111" title="">'+n+'</div><div class="per101  cell height111" title="'+v.ps_quantity+'">'+v.ps_quantity+'</div><div class="per101 cell height111" title="'+v.ps_quantity_hold+'">'+v.ps_quantity_hold+'</div><div class="per101 cell height111" title="'+v.ps_create_date+'">'+v.ps_create_date+'</div><div class="per101  height111 cell" title="'+v.ps_last_update+'">'+v.ps_last_update+'</div></div>'
						});
						html += '<div class="pagination" style="padding-top:10px" title="inventory"></div>';
						$(".info-content-body").html(html);
						$(".pagination").pagination(json.total, { 
							  callback: function(page_id){
								paginationCurrentPage = page_id+1;
								paginationTotal = json.total;
								$(".tab-li:eq(5)").click();
							  },
							  first_text:'First',
							  prev_text: '< Previous', 
							  next_text: 'Next >', 
							  last_text: 'Last',
							  perpage_text: 'PerPage',
							  total_text: 'Total',
							  items_per_page: paginationPageSize, 
							  num_display_entries: 6, 
							  current_page: paginationCurrentPage - 1, 
							  num_edge_entries: 2 
						 });
					}else{
						$(".info-content-body").html("<div style='width:100%;text-align:center'>No Result</div>");
					}
					closeLoading();
				}
			});
		});
		
		
		$(".tab-li:eq(6)").click(function(){
			if(currentTab!=6){
				paginationCurrentPage = 1;
			}
			currentTab = 6;
			loading();
			$.ajax({
				url:"/product/product/get-porduct-stocket-log/productId/"+productId+"/page/"+paginationCurrentPage+"/pageSize/"+paginationPageSize+"/"+new Date(),
				async:false,
				dataType:"json",
				success:function(json){
					if(json.ask){
						var html = '<div class="row height25 row-header"><div class="per101  cell">ID</div><div class="per102  cell">User</div><div class="per103 cell">Time</div><div class="per104 cell">Note</div></div>';
						$.each(json.results,function(k,v){
						    var n=k+1;
							html += '<div class="row height111"><div class="per101  cell height111" title="">'+n+'</div><div class="per102  cell height111" title="'+v.user_id+'">'+v.user_id+'</div><div class="per103 cell height111" title="'+v.psl_add_time+'">'+v.psl_add_time+'</div><div class="per104 cell height111" title="'+v.psl_note+'">'+v.psl_note+'</div></div>'
						});
						html += '<div class="pagination" style="padding-top:10px" title="InventoryLog"></div>';
						$(".info-content-body").html(html);
						$(".pagination").pagination(json.total, { 
							  callback: function(page_id){
								paginationCurrentPage = page_id+1;
								paginationTotal = json.total;
								$(".tab-li:eq(6)").click();
							  },
							  first_text:'First',
							  prev_text: '< Previous', 
							  next_text: 'Next >', 
							  last_text: 'Last',
							  perpage_text: 'PerPage',
							  total_text: 'Total',
							  items_per_page: paginationPageSize, 
							  num_display_entries: 6, 
							  current_page: paginationCurrentPage - 1, 
							  num_edge_entries: 2 
						 });
					}else{
						$(".info-content-body").html("<div style='width:100%;text-align:center'>No Result</div>");
					}
					closeLoading();
				}
			});
		});
		
		
		
		$(".tab-li:eq(8)").click(function(){	//ASN Log
			if(currentTab!=8){
				paginationCurrentPage = 1;
			}
			currentTab = 8;					
			loading();
	
			$.ajax({
				url:"/product/product/asn-log/productId/"+productId+"/page/"+paginationCurrentPage+"/pageSize/"+paginationPageSize+"/"+new Date(),
				async:false,
				dataType:"json",
				success:function(json){
					if(json.ask){
						var html = '<div class="row height25 row-header">' +
								'<div class="width10 no-background">ASN NO.</div>' +
								'<div class="width10 no-background">product quantity</div>' +
								'<div class="width10 no-background">status</div>' +
								'<div class="width10 no-background">add_time</div>' +
								'</div>';
						if(json.result.logs.length){							
							
							$.each(json.result.logs,function(k,v){
								html += '<div class="row height25">' +
											'<div class="width10 no-background" title="'+v.receiving_code+'">'+
											v.receiving_code+
											'</div>' +
											'<div class="width10 no-background" title="'+v.received_qty+'">'+
											v.received_qty+
											'</div>' +
											'<div class="width10 no-background" title="'+v.status+'">'+
											v.status+
											'</div>' +
											'<div class="width10 no-background" title="'+v.created+'">'+
											v.created+
											'</div>' +
										'</div>'
							});
							
							html += '<div class="pagination" style="padding-top:10px" title="log"></div>';
							$(".info-content-body").html(html);	
							$(".pagination").pagination(json.result.total, { 
								  callback: function(page_id){
									paginationCurrentPage = page_id+1;
									paginationTotal = json.result.total;
									$(".tab-li:eq(8)").click();
								  },
								  first_text:'First',
								  prev_text: '< Previous', 
								  next_text: 'Next >', 
								  last_text: 'Last',
								  perpage_text: 'PerPage',
								  total_text: 'Total',
								  items_per_page: paginationPageSize, 
								  num_display_entries: 6, 
								  current_page: paginationCurrentPage - 1, 
								  num_edge_entries: 2 
							 });
						}else{
							html += '<div class="row height25" style="text-align:center;">No data returns</div>'							
							$(".info-content-body").html(html);
						}
					}else{
						$(".info-content-body").html("<div style='width:100%;text-align:center'>No Result</div>");
					}
					closeLoading();
				}
			});
			
		});
		
		$("#addLinkPictureDialog").dialog({
			autoOpen:false,
			modal:true
		});
		
		$(".addLinkPicture").live("click",function(){
			var html = '<div><div>URL:<input type="text" class="linkUrl"/><span class="delUrlInput"><img src="/images/minus_sign.gif" /></span></div><div class="addUrlInput"><img src="/images/plus_sign.gif"/><input type="button" value="Add" class="addUrl"/></div></div>'
			$("#addLinkPictureDialog").html(html);
			$("#addLinkPictureDialog").dialog("open");
		});
		
		$(".addUrlInput").live("click",function(){
			var html ='<div>URL:<input type="text" class="linkUrl"/><span class="delUrlInput"><img src="/images/minus_sign.gif"/></span></div>';
			$(".addUrlInput").before(html);
		});
		
		$(".delUrlInput").live("click",function(){
			$(this).parent().remove();
		});
		
		$(".addUrl").live("click",function(){
			var iWidth = $(".product-img-view").width();
				var iHeight = $(".product-img-view").height();
				$.each($(".linkUrl"),function(k,v){
					$("#imagePlaceholder").remove();
					$(".uploadFile").before('<div class="product-img-view" onclick="removePicture(this)"><img src="'+$(v).val()+'" width="'+ iWidth +'" height="'+iHeight+'"/><input type="hidden" name="link[]" value="'+$(v).val()+'"/></div>');
					$("product-img-view").css("text-indent","0");
					if($(".product-img-view").length > 3){
						$("#height110").removeClass("height110");
					}
				});
				$("#addLinkPictureDialog").dialog("close");
				var html = '<div><div>URL:<input type="text" class="linkUrl"/><span class="delUrlInput"><img src="/images/minus_sign.gif" /></span></div><div class="addUrlInput"><img src="/images/plus_sign.gif"/><input type="button" value="Add" class="addUrl"/></div></div>'
				$("#addLinkPictureDialog").html(html);
		});

	//初始执行
	loadProduct();		
	$(".tab-li:eq(0)").click();
	
	<{if $edit == "true"}>
		$("[name=modify]").click();
	<{/if}>
	
	<{if $qcset == "true"}>
		$(".tab-li:eq(6)").click();
	<{/if}>
	
});
	
function loadProduct(){
	$.ajax({
		url:"/product/product/get-product-info/productId/"+productId+"/"+new Date(),
		dataType:"json",
		async:false,
		success:function(json){
			if(json.ask){
				var html ='';
				var val = json.result;
				html += '<div class="cell20"><{$lang.sku}>:</div>'; 
				html += '<div class="cell30">'+val.product.product_sku+'</div>';
				html += '<div class="cell20">Status:</div>';					
				html += '<div class="cell30 no-right">'+val.product.product_status+'</div>';
					
				html += '<div class="cell20 no-bottom"><{$lang.sku}> Name:</div>';
				html += '<div class="cell30 no-bottom">'+val.product.product_title+'</div>';
				html += '<div class="cell20 no-bottom">Create Date:</div>';
				html += '<div class="cell30 no-bottom no-right">'+val.product.product_date_added+'</div>';
			}
			$(".info-header-content").html(html);
		}
	});
}
	
function changePageSize(obj){
	paginationPageSize = $(obj).val();
	if(paginationPageSize <= 0){
		paginationPageSize = 20;
	}
		
	if(Math.ceil(paginationTotal/paginationPageSize) <= paginationCurrentPage){
		paginationCurrentPage = Math.ceil(paginationTotal/paginationPageSize);
	}
	if(paginationCurrentPage == 0){
		paginationCurrentPage = 1;
	}
	eval($(".pagination").attr("title")+'()');
}
	
function log(){
	$(".tab-li:eq(1)").click();
}
	
function inventory(){
	$(".tab-li:eq(5)").click();
}

function InventoryLog(){
   $(".tab-li:eq(6)").click();
}

</script>

<style type="text/css">
body{font:normal normal normal 12px/150% "Segoe UI",Tahoma,Verdana,Arial; color:#333; margin:0; padding:0; background:#FFF}
/*-----Main-----*/

.main{width:900px; margin:auto; background:url(../images/main-bg.png) repeat-y left top; _background:url(../images/main-bg.gif) repeat-y left top;}
.main-body{min-height:300px; background:url(../images/main-top-bg.png) no-repeat  l top none; padding:0; position:relative; z-index:100;border:1px solid #cccccc}
.main-bottom{ background:url(../images/main-bottom-bg.png) no-repeat center top; _background:url(../images/main-bottom-bg.gif) no-repeat center top; height:7px;}


.bgc{ background:#F2F8FD; }
.radiu{
	-webkit-border-radius: 10px;
	-moz-border-radius:10px;
	border-radius:10px;
	overflow: hidden;
}
.info-top{ height:10px; }
.tab-li{ 
	float:left; padding:0; 
	cursor:pointer; 
	background:url(/images/menu-li-bg.gif) no-repeat center top; 
	width:92px; height:25px; line-height:25px;
	text-align:center; color:white;
}
.tab-li-click{
	background:url(/images/menu-li-bg-hover.gif) no-repeat center top;
}
.tab-li:hover{
	background:url(/images/menu-li-bg-hover.gif) no-repeat center top;
}
.info-header{
	width:100%;height:200px;
	border-bottom:1px solid #CCC;
	position:relative;
}
.info-header h3{
	text-indent:10px;
}
.info-content{}
.info-content-body{
	border-top:1px solid #CCC;
	width:100%;
	clear:both;
	min-height: 200px;
}
.info-content-menu{
	border-top:1px solid #CCC;
	width:100%;
}
.info-header-content{
	position:absolute;top:50px;left:10px;
	width:870px;border:1px solid #CCC;
}
.cell20{
	width:180px;height:25px;line-height:25px;
	display:inline-block;
	overflow:hidden;
	border-bottom:1px solid #CCC;border-right:1px solid #CCC;
	margin:0px;float:left;
}
.cell30{
	width:253px;height:25px;line-height:25px;
	display:inline-block;
	overflow:hidden;
	border-bottom:1px solid #CCC;border-right:1px solid #CCC;
	margin:0px;margin:0px;float:left;
}
.no-bottom{border-bottom:none}
.no-right{border-right:none}
.error{color:red}
</style>
</head>
<body class="bgc">

<div class="info-top"></div>

<div class="main">
	<div class="main-body">
		<div class="content bgc">

			<div class="info-header">
				<h3 class="">Product Details</h3>
				<div class="info-header-content">	</div>
				
			</div>
			<div class="info-content">
				<div class="info-content-menu bgc">
					<ul class="bgc">
						<li class="tab-li tab-li-click">Information</li>
						<li class="tab-li">Log</li>
						<li class="tab-li">Image</li>
						<li class="tab-li">Order</li>
						<li class="tab-li" style='display:none;'>Attachs</li>
						<li class="tab-li">Inventory</li>
						<li class="tab-li">InventoryLog</li>
                        <li class="tab-li">Quality Control</li>
                        <li class="tab-li">ASN Log</li>
					</ul>
				</div>
				<div class="info-content-body">	</div>
			
			</div>

		</div>
	</div>

	<div class="main-bottom"></div>
</div>

<div id="uploadFileDialog" style="display:none" title="images upload">
	<div id="fileQueue"></div>
	<input type="file" id="uploadify" class="half" value="" name="uploadify"/>
</div>
<div id="addLinkPictureDialog" style="display:none" title="Add picture">
	
</div>
<div id="tip" style="display:none" title="Tip">
	<{$lang.sku}> does not exist
</div>
<div id="qcItemCheck" style="display:none;"></div>
</body>
</html>
